package com.decent.manager.system.auth.controller;

import com.decent.common.bo.MessageBean;
import com.decent.manager.config.security.annotion.BasicPermission;
import com.decent.manager.system.auth.content.LoginContextHandler;
import com.decent.manager.system.auth.service.AuthService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 张子旭
 * @date 2022/1/21
 */
@RequestMapping("/auth")
@RestController
public class LoginController {
    @Resource
    private AuthService authService;

    /**
     * 退出登录
     */
    @BasicPermission
    @RequestMapping("/logout")
    public MessageBean logout() {
        return authService.logout();
    }

    /**
     * 获取当前登录用户信息
     */
    @BasicPermission
    @RequestMapping("/getLoginUser")
    public MessageBean getLoginUser() {
        return MessageBean.success(LoginContextHandler.current().getLoginUserUpToDate());
    }
}
